<!DOCTYPE html>
<html lang="en">
<head>
    {include file="public/meta" /}
    {include file="public/link" /}
    <style>
        .red{
            color: red;
        }
        .green{
            color: green;
        }
    </style>
</head>
<body data-type="index" class="theme-white">
<div class="am-g tpl-g">
    {include file="public/header" /}
    {include file="public/left" /}
    {include file="public/content_top" /}
    <ol class="am-breadcrumb">
        <li><a href="../home/index.html" class="am-icon-home">首页</a></li>
        <li><a href="#">订单管理</a></li>
        <li class="am-active">当日成交</li>
    </ol>
    <div class="widget am-cf">
        <div class="am-form-inline" role="form">
            <span>日期范围：</span>
            <div class="am-form-group ">
                <input type="datetime-local" class="am-form-field am-input-sm" name="start" placeholder="请选择起始日期"
                        onfocus="this.blur()" value="{$arr.start_query}"/>
            </div>
            <div class="am-form-group ">
                <input type="datetime-local" class="am-form-field am-input-sm" name="end" placeholder="请选择结束日期"  onfocus="this.blur()" value="{$arr.end_query}"/>
            </div>
           <span>用户/订单：</span>
            <div class="am-form-group ">
                <input type="text" id="name" class="am-form-field am-input-sm" placeholder="订单号/用户" value="{$arr.name}"/>
            </div>
            <!-- <span>代理id：</span>
            <div class="am-form-group ">
                <input type="text" id="order"  name="order" class="am-form-field am-input-sm" placeholder="代理id" value="{$arr.order}"/>
            </div> -->
            <button type="button" class="am-btn am-btn-primary am-btn-sm" onclick="info_query()">查询</button>
            <button type="button" class="am-btn am-btn-warning am-btn-sm" onclick="clear_query()">清除查询</button>
        </div>
        <hr data-am-widget="divider" class="am-divider am-divider-default"/>
        <div class="widget-body widget-body-lg am-fr">
            <div class="am-scrollable-horizontal">
                <table class="{$table}">
                    <thead>
                    <tr>
                        <th>用户ID</th>
                        <th>订单编号</th>
                        <th>用户信息</th>
                        <th>成交时间</th>
                        <th>结算时间</th>
                        <th>货币名称</th>
                        <th>成交价格</th>
                        <th>结算价格</th>
                        <th>交易方向</th>
                        <th>投资金额</th>
                        <th>手续费</th>
                        <th>盈亏</th>
                        <th>状态</th>
                        <th>设置</th>
                        <th>操作</th> 
                    </tr>
                    </thead>
                    <tbody id="list">
                    {foreach $list as $val}
                    <tr class="text-c">
                        <td>{$val.uid}</td>
                        <td class="red">{$val.order}</td>
                        <td>{$val.user.real_name}-{$val.user.phone}</td>
                        <td>{$val.time}</td>
                        <td>{$val.clear_time}</td>
                        <td>{$val.name}</td>
                        <td>{$val.buy_price}</td>
                        <td>{$val.selling_price}</td>
                        {if condition="$val.type eq '订购'"}
                            <td class="red">{$val.type}</td>
                        {else /}
                            <td class="green">{$val.type}</td>
                        {/if}
                        <td>{$val.number}</td>
                        <td>{$val.fee}</td>
                        {if condition="($val.profit_loss > 0) "}
                            <td class="red">{$val.profit_loss}</td>
                        {elseif condition="$val.profit_loss eq 0"/} 
                            <td >{$val.profit_loss}</td>
                        {else /}
                            <td class="green">{$val.profit_loss}</td>
                        {/if}
                        <td>{$val.status_text}</td>
                        <td>{$val.is_win_text}</td>
                        {if condition="$val.status eq '1'"}
                        <td>
                            <a href="#" class="am-btn am-btn-warning am-btn-xs">已结算</a>
                            <a href="edits?id={$val.id}" class="am-btn am-btn-warning am-btn-xs">修改</a>
                        </td>
                        {else /}
                        <td>
                            {if condition="$val.is_win eq '1'"}
                            <a href="#" onclick="sub({$val['id']},2)" class="am-btn am-btn-success am-btn-xs">已赢</a>
                            {elseif condition="$val.is_win eq 2"/}
                            <a href="#" onclick="sub({$val['id']},1)" class="am-btn am-btn-warning am-btn-xs">已输</a>
                            {else /}
                            <a href="#" onclick="sub({$val['id']},1)" class="am-btn am-btn-success am-btn-xs">赢</a>
                            <a href="#" onclick="sub({$val['id']},2)" class="am-btn am-btn-warning am-btn-xs">输</a>
                            {/if}
                            <a href="edits?id={$val.id}" class="am-btn am-btn-warning am-btn-xs">修改</a>
                        </td>
                        {/if}

                    </tr>
                    {/foreach}
                    <tr>
                      <th colspan="5" >盈亏统计:¥{$profit_loss}</th>
                      <th colspan="5">交易流水统计:¥{$num}</th>
                      <th colspan="5">手续费统计:¥{$fee}</th>
                  </tr>    
                    </tbody>
                </table>
                <div class="am-pagination-left">{$page}</div>
            </div>
        </div>
    </div>
</div>
{include file="public/foot" /}
<script type="text/javascript">

    $(function () {
        var nav = $('.left-sidebar li.sidebar-nav-link');
        nav.removeClass("active");
        nav.eq(2).find('ul').show();
        nav.eq(2).find('ul li').eq(2).find('a').addClass('active');
    });

    function sub(id, status) {
        $.ajax({
            url: "{:url('Count/edit')}",
            type: "post",
            data: {id: id, status: status},
            success: function (r) {
                if (r['code'] == 1) {
                    layer.msg(r['msg']);
                    setTimeout(function () {
                        window.location.reload();
                    }, 1500);
                } else {
                    layer.msg(r['msg']);
                }
            }
        });
    }
</script>
</body>
</html>
